package org.springblade.tms.global.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springblade.common.enums.Enumerator;

/**
 * @projectName: BladeX
 * @package: org.springblade.tms.global.enums
 * @className: whetherEnum
 * @author: yr
 * @description: 是否枚举
 * @date: 2022/3/15 17:17
 */
@Getter
@AllArgsConstructor
public enum WhetherEnum implements Enumerator {
	yes(1, "是"),
	no(0, "否");
	private final Integer value;
	private final String description;

	@Override
	public String value() {
		return value.toString();
	}

	@Override
	public String description() {
		return description;
	}

	public static Integer getDescriptionByValue(String description) {
		for (WhetherEnum whetherEnum : WhetherEnum.values()) {
			if (whetherEnum.getDescription().equals(description)) {
				return whetherEnum.getValue();
			}
		}
		return null;
	}

	public static String getValueByDescription(Integer value) {
		for (WhetherEnum whetherEnum : WhetherEnum.values()) {
			if (whetherEnum.getValue().equals(value)) {
				return whetherEnum.getDescription();
			}
		}
		return null;
	}
}
